package com.pan.frame.other;

import javax.swing.*;
import java.awt.*;

public class TipsFrame {


    private JFrame frame;
    private JLabel tipLbl;
    private JLabel titleLbl;
    public TipsFrame(String title,String tip) {
        int lineSize = 24;
        String content = "<html><center>";
        for (int i = 0; i <= tip.length() / lineSize; i++) {
            content +=tip.substring(
                    i*lineSize,
                    i*lineSize+lineSize>tip.length()?tip.length():i*lineSize+lineSize);
            content += "<br/>";
        }
        content+="</center></html>";

        frame = new JFrame(title);
        frame.setSize(400,200);
        frame.setLayout(null);
        frame.setResizable(false);

        titleLbl = new JLabel(title);
        titleLbl.setFont(new Font("SimSun",Font.BOLD,26));
        titleLbl.setBounds(120,20,140,40);
        frame.add(titleLbl);

        tipLbl = new JLabel();
        tipLbl.setBounds(80,60,240,100);
        tipLbl.setFont(new Font("SimSun",Font.PLAIN,18));
        tipLbl.setLayout(new FlowLayout());
        tipLbl.setPreferredSize(new Dimension(240,120));
        tipLbl.setText(content);

        frame.add(tipLbl);

        frame.setVisible(true);

    }

    public static void main(String[] args) {
        new TipsFrame("tips",">1145----adajjjjjjhhhhhhhhhhh立刻觉得哈看见对方啊的数据库和法律教科书的好伐拉省的安居客DHL撒看见共和国和");
    }
}
